import {Vue, Component} from 'vue-property-decorator';
import Item from './_components/item.vue';
import { postWithdrawalRecord } from '@/request/actions';
import PageBottom from '@components/pageBottom/index.vue'


@Component({
    components:{
        Item,
        PageBottom
    }
})
export default class extends Vue {

    salonId:string|number = '';
    userId:string|number = '';
    page:number = 1 ;
    limit:number = 10;
    bStop:boolean = true;
    loadingType:string|number = 'none';
    list:Array<any> = [];

    
    WithdrawalRecord(arr:Array<any> = []){

        let page = this.page;
        let limit = this.limit;
        let globalData = getApp().globalData;
        let {userId} = globalData.userInfo;
        let list:Array<any> = arr;
        
        uni.showLoading();


        postWithdrawalRecord({
            page,limit,userId
        }).then((r:any)=>{

            let {data:res} = r;


            
            if(res.status == 200){
                list.push(...res.data);
                this.list = list;
             
                if(res.count == 0){
                    this.loadingType = 0;
                   
                }else if(res.count == this.list.length){

                    console.log(12312321)
                    this.loadingType = 1;

                }
            }
            this.bStop = res.data.length < limit ?  false : true;
           
            uni.hideLoading();

        })


    }
    scrolltolower(){
     
        this.page++;
   
        if(!this.bStop) return;
        
       
        this.WithdrawalRecord(this.list); 
   }
    
    onLoad(query:any){
        this.salonId = query.salonId;
        this.WithdrawalRecord();
    }

}